/// [Triangular, pentagonal, and hexagonal](https://projecteuler.net/problem=45)
fn main() {
    let mut p = (1, 1);
    let mut h = (1, 1);
    for (i, t) in (286_u64..).map(|x| (x, x * (x + 1) / 2)) {
        while p.1 < t {
            p.0 += 1;
            p.1 = p.0 * (p.0 * 3 - 1) / 2;
        }
        while h.1 < t {
            h.0 += 1;
            h.1 = h.0 * (h.0 * 2 - 1);
        }
        if p.1 == t && h.1 == t {
            println!("{},{}", i, t);
            break;
        }
    }
}
